package com.ruoyi.web.controller.bus;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bus.domain.WitRoute;
import com.ruoyi.bus.service.IWitRouteService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 路线Controller
 * 
 * @author caiyanshan
 * @date 2021-04-14
 */
@RestController
@RequestMapping("/bus/route")
public class WitRouteController extends BaseController
{
    @Autowired
    private IWitRouteService witRouteService;

    /**
     * 查询路线列表
     */
    @PreAuthorize("@ss.hasPermi('bus:route:list')")
    @GetMapping("/list")
    public TableDataInfo list(WitRoute witRoute)
    {
        startPage();
        List<WitRoute> list = witRouteService.selectWitRouteList(witRoute);
        return getDataTable(list);
    }

    /**
     * 导出路线列表
     */
    @PreAuthorize("@ss.hasPermi('bus:route:export')")
    @Log(title = "路线", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WitRoute witRoute)
    {
        List<WitRoute> list = witRouteService.selectWitRouteList(witRoute);
        ExcelUtil<WitRoute> util = new ExcelUtil<WitRoute>(WitRoute.class);
        return util.exportExcel(list, "route");
    }

    /**
     * 获取路线详细信息
     */
    @PreAuthorize("@ss.hasPermi('bus:route:query')")
    @GetMapping(value = "/{routeId}")
    public AjaxResult getInfo(@PathVariable("routeId") Long routeId)
    {
        return AjaxResult.success(witRouteService.selectWitRouteById(routeId));
    }

    /**
     * 新增路线
     */
    @PreAuthorize("@ss.hasPermi('bus:route:add')")
    @Log(title = "路线", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WitRoute witRoute)
    {
        return toAjax(witRouteService.insertWitRoute(witRoute));
    }

    /**
     * 修改路线
     */
    @PreAuthorize("@ss.hasPermi('bus:route:edit')")
    @Log(title = "路线", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WitRoute witRoute)
    {
        return toAjax(witRouteService.updateWitRoute(witRoute));
    }

    /**
     * 删除路线
     */
    @PreAuthorize("@ss.hasPermi('bus:route:remove')")
    @Log(title = "路线", businessType = BusinessType.DELETE)
	  @DeleteMapping("/{routeIds}")
    public AjaxResult remove(@PathVariable Long[] routeIds)
    {
        return toAjax(witRouteService.deleteWitRouteByIds(routeIds));
    }
}
